<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>Title</title>
    <script type="text/javascript">
        //json的定义

        var jsonObj={
            "key1":12,
            "key2":"abc",
            "key3":true,
            "key4":[11,"arr",false],
            "key5":{
                "key5_1":551,
                "key5_2":"key5_2_value"
            },
            "key6":[{
                "key6_1_1":6611,
                "key6_1_2":"key6_1_2_value"
            },{
                "key6_2_1":6621,
                "key6_2_2":"key6_2_2_value"
            }]
        }
        /**
         * alert(typeof (jsonObj)); //json就是一个对象
         * json中数组值的遍历
         *   for(var i=0;i<jsonObj.key4.length;i++{
         *       alter(jsonObj.key4[i])
         *   }
         *
         *   alert(typeof (jsonObj.key5.key5_1));//551
         *
         *   //取出的都是json值
         *   var jsonItem=jsonObj.key6[0];
         *   alter(jsonItem.key6_1_1);//6611
         *
         *
         *
         * */


        //json的访问
        //json对象转字符串
        var jsonObjString =JSON.stringify(jsonObj);//特别像Java的tostring
        //alter(jsonObjString)

        //json字符串转json对象
        var jsonObj2=JSON.parse(jsonObjString)
        //alter(jsonObj2.key2);abc
    </script>
</head>
<body>

</body>
</html>